package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.UserDAO;
import dao.UserDaoJdbcImpl;
import dao.UserInfoDAO;
import dao.UserInfoDaoJdbcImpl;
import modle.userInfo;

/**
 * Servlet implementation class UserUpdateServlet
 */
@WebServlet("/UserUpdateServlet")
public class UserUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UserUpdateServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String userName = request.getParameter("userName"); //用户名
		String usercredit = request.getParameter("usercredit"); //学号
		String name = request.getParameter("name");
		String userEmail = request.getParameter("userEmail");
		String userSex = request.getParameter("userSex");
		String userStatus = request.getParameter("userStatus");
		userInfo userInfo = new userInfo(userName, usercredit, name, userEmail, userSex, Integer.parseInt(userStatus));
		UserInfoDAO uid = new UserInfoDaoJdbcImpl();
		uid.updateUserInfo(userInfo);
//		UserDAO usd = new UserDaoJdbcImpl();
//		usd.changeUsername(userName);
		
		System.out.println(userSex);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
